//
//  ZXCheckAppItunesVersionManager.h
//  CollagePicture
//
//  Created by simon on 16/11/18.
//  Copyright © 2016年 sina. All rights reserved.
//
//  2018.03.26  修改固定路径为类目获取；
//  2018.05.10  优化代码
//  2020.01.21  优化代码
//  2021.08.16  优化代码，

#import "CAIItunesModel.h"


NS_ASSUME_NONNULL_BEGIN

#ifndef WS
#define WS(weakSelf)  __weak __typeof(&*self)weakSelf = self;
#endif

///目前appStore有点小问题：在appStore上已经通过审核，1天内刚发布的版本，用这个链接地址检查不到，只能检查到上一个版本。

@interface ZXCheckAppItunesVersionManager : NSObject




/// 根据appId检查itunes是否有新版本
/// @param appleID 唯一appleID
/// @param success 检查成功回调，是否需要更新
/// @param failure 检查失败
+ (void)checkAppStoreNewVersionWithAppleID:(NSString *)appleID
                                   success:(nullable void(^)(BOOL isHaveNewVersion,CAIItunesModel *itunesModel))success
                                   failure:(nullable void(^)(NSError *error))failure;


/// 根据url地址检查itunes是否有新版本
/// @param url appstore链接地址
/// @param success 检查成功回调，是否需要更新
/// @param failure 检查失败
+ (void)checkAppStoreNewVersionWithUrl:(NSString *)url
                               success:(nullable void(^)(BOOL isHaveNewVersion,CAIItunesModel *itunesModel))success
                               failure:(nullable void(^)(NSError *error))failure;
@end

NS_ASSUME_NONNULL_END
/*
 {
 resultCount = 1;
 results = (
 {
 primaryGenreName = Utilities;
 artworkUrl100 = https://is1-ssl.mzstatic.com/image/thumb/Purple116/v4/ae/5b/00/ae5b0094-6a0f-3049-4f30-e421a53ec3c0/AppIcon-1x_U007emarketing-0-5-0-0-85-220.png/100x100bb.jpg;
 currency = CNY;
 artworkUrl512 = https://is1-ssl.mzstatic.com/image/thumb/Purple116/v4/ae/5b/00/ae5b0094-6a0f-3049-4f30-e421a53ec3c0/AppIcon-1x_U007emarketing-0-5-0-0-85-220.png/512x512bb.jpg;
 ipadScreenshotUrls = (
 );
 fileSizeBytes = 66020352;
 genres = (
 工具
 );
 languageCodesISO2A = (
 EN
 );
 artworkUrl60 = https://is1-ssl.mzstatic.com/image/thumb/Purple116/v4/ae/5b/00/ae5b0094-6a0f-3049-4f30-e421a53ec3c0/AppIcon-1x_U007emarketing-0-5-0-0-85-220.png/60x60bb.jpg;
 supportedDevices = (
 iPhone5s-iPhone5s,
 iPadAir-iPadAir,
 iPadAirCellular-iPadAirCellular,
 iPadMiniRetina-iPadMiniRetina,
 iPadMiniRetinaCellular-iPadMiniRetinaCellular,
 iPhone6-iPhone6,
 iPhone6Plus-iPhone6Plus,
 iPadAir2-iPadAir2,
 iPadAir2Cellular-iPadAir2Cellular,
 iPadMini3-iPadMini3,
 iPadMini3Cellular-iPadMini3Cellular,
 iPodTouchSixthGen-iPodTouchSixthGen,
 iPhone6s-iPhone6s,
 iPhone6sPlus-iPhone6sPlus,
 iPadMini4-iPadMini4,
 iPadMini4Cellular-iPadMini4Cellular,
 iPadPro-iPadPro,
 iPadProCellular-iPadProCellular,
 iPadPro97-iPadPro97,
 iPadPro97Cellular-iPadPro97Cellular,
 iPhoneSE-iPhoneSE,
 iPhone7-iPhone7,
 iPhone7Plus-iPhone7Plus,
 iPad611-iPad611,
 iPad612-iPad612,
 iPad71-iPad71,
 iPad72-iPad72,
 iPad73-iPad73,
 iPad74-iPad74,
 iPhone8-iPhone8,
 iPhone8Plus-iPhone8Plus,
 iPhoneX-iPhoneX,
 iPad75-iPad75,
 iPad76-iPad76,
 iPhoneXS-iPhoneXS,
 iPhoneXSMax-iPhoneXSMax,
 iPhoneXR-iPhoneXR,
 iPad812-iPad812,
 iPad834-iPad834,
 iPad856-iPad856,
 iPad878-iPad878,
 iPadMini5-iPadMini5,
 iPadMini5Cellular-iPadMini5Cellular,
 iPadAir3-iPadAir3,
 iPadAir3Cellular-iPadAir3Cellular,
 iPodTouchSeventhGen-iPodTouchSeventhGen,
 iPhone11-iPhone11,
 iPhone11Pro-iPhone11Pro,
 iPadSeventhGen-iPadSeventhGen,
 iPadSeventhGenCellular-iPadSeventhGenCellular,
 iPhone11ProMax-iPhone11ProMax,
 iPhoneSESecondGen-iPhoneSESecondGen,
 iPadProSecondGen-iPadProSecondGen,
 iPadProSecondGenCellular-iPadProSecondGenCellular,
 iPadProFourthGen-iPadProFourthGen,
 iPadProFourthGenCellular-iPadProFourthGenCellular,
 iPhone12Mini-iPhone12Mini,
 iPhone12-iPhone12,
 iPhone12Pro-iPhone12Pro,
 iPhone12ProMax-iPhone12ProMax,
 iPadAir4-iPadAir4,
 iPadAir4Cellular-iPadAir4Cellular,
 iPadEighthGen-iPadEighthGen,
 iPadEighthGenCellular-iPadEighthGenCellular,
 iPadProThirdGen-iPadProThirdGen,
 iPadProThirdGenCellular-iPadProThirdGenCellular,
 iPadProFifthGen-iPadProFifthGen,
 iPadProFifthGenCellular-iPadProFifthGenCellular,
 iPhone13Pro-iPhone13Pro,
 iPhone13ProMax-iPhone13ProMax,
 iPhone13Mini-iPhone13Mini,
 iPhone13-iPhone13,
 iPadMiniSixthGen-iPadMiniSixthGen,
 iPadMiniSixthGenCellular-iPadMiniSixthGenCellular,
 iPadNinthGen-iPadNinthGen,
 iPadNinthGenCellular-iPadNinthGenCellular,
 iPhoneSEThirdGen-iPhoneSEThirdGen,
 iPadAirFifthGen-iPadAirFifthGen,
 iPadAirFifthGenCellular-iPadAirFifthGenCellular,
 iPhone14-iPhone14,
 iPhone14Plus-iPhone14Plus,
 iPhone14Pro-iPhone14Pro,
 iPhone14ProMax-iPhone14ProMax,
 iPadTenthGen-iPadTenthGen,
 iPadTenthGenCellular-iPadTenthGenCellular,
 iPadPro11FourthGen-iPadPro11FourthGen,
 iPadPro11FourthGenCellular-iPadPro11FourthGenCellular,
 iPadProSixthGen-iPadProSixthGen,
 iPadProSixthGenCellular-iPadProSixthGenCellular,
 iPhone15-iPhone15,
 iPhone15Plus-iPhone15Plus,
 iPhone15Pro-iPhone15Pro,
 iPhone15ProMax-iPhone15ProMax,
 iPadAir11M2-iPadAir11M2,
 iPadAir11M2Cellular-iPadAir11M2Cellular,
 iPadAir13M2-iPadAir13M2,
 iPadAir13M2Cellular-iPadAir13M2Cellular,
 iPadPro11M4-iPadPro11M4,
 iPadPro11M4Cellular-iPadPro11M4Cellular,
 iPadPro13M4-iPadPro13M4,
 iPadPro13M4Cellular-iPadPro13M4Cellular
 );
 description = 进货就要菜划算（该应用为菜划算-司机端）
 【公司介绍】
 作为浙江省市重点民生保供企业，菜划算进货涵盖中小商户所需的近万款食材商品。
 覆盖水果蔬菜、肉禽水产、酒饮乳品、粮油百货、餐厨调味等全品类食材。
 我们致力于从田间到商户的全链路保障服务，去除中间环节，确保质优价美。
 全自营采仓配生产管理，让食材更安心，进货更放心。进货就要菜划算！
 配送任务，直观明晰；配送线路，精确导航。;
 bundleId = com.Chs.MerchantDriverApp;
 trackViewUrl = https://apps.apple.com/cn/app/%E8%8F%9C%E5%88%92%E7%AE%97%E5%8F%B8%E6%9C%BA/id1512313756?uo=4;
 version = 2.7.0;
 artistViewUrl = https://apps.apple.com/cn/developer/%E6%9D%AD%E5%B7%9E%E8%8F%9C%E5%88%92%E7%AE%97%E7%BD%91%E7%BB%9C%E7%A7%91%E6%8A%80%E6%9C%89%E9%99%90%E5%85%AC%E5%8F%B8/id1452131584?uo=4;
 releaseDate = 2020-05-15T07:00:00Z;
 isGameCenterEnabled = 0;
 appletvScreenshotUrls = (
 );
 genreIds = (
 6002
 );
 averageUserRatingForCurrentVersion = 3.1176499999999998102850895520532503724;
 userRatingCountForCurrentVersion = 17;
 trackId = 1512313756;
 wrapperType = software;
 minimumOsVersion = 9.0;
 formattedPrice = 免费;
 primaryGenreId = 6002;
 currentVersionReleaseDate = 2023-07-06T02:09:43Z;
 userRatingCount = 17;
 artistId = 1452131584;
 artistName = xxxxxxx有限公司;
 trackContentRating = 12+;
 price = 0;
 trackCensoredName = 菜划算司机;
 trackName = 菜划算司机;
 kind = software;
 features = (
 );
 contentAdvisoryRating = 12+;
 screenshotUrls = (
 https://is1-ssl.mzstatic.com/image/thumb/Purple115/v4/18/e5/ef/18e5ef37-885b-f0ae-1899-feef3ffdf11a/e0fe2c89-d37b-4bec-8855-77b2a15f1c14_1242x2208-1.png/392x696bb.png,
 https://is1-ssl.mzstatic.com/image/thumb/Purple115/v4/1c/69/c2/1c69c217-3226-f679-06a5-d92d25f86d2d/1cc31534-d97a-44a2-a01f-6ffd12e132d5_1242x2208-2.png/392x696bb.png,
 https://is1-ssl.mzstatic.com/image/thumb/Purple115/v4/36/bc/2b/36bc2b4b-ea8b-cf6d-3116-7535bf415543/d9123646-c6d0-4bc1-ad1a-3d6782b50612_1242x2208-3_U5907_U4efd.png/392x696bb.png,
 https://is1-ssl.mzstatic.com/image/thumb/Purple115/v4/03/4e/56/034e56a4-78ab-846e-2a61-350dd99b7369/c59486b3-0245-4a08-bc0a-b5ed3152e811_1242x2208-3.png/392x696bb.png,
 https://is1-ssl.mzstatic.com/image/thumb/PurpleSource115/v4/9e/4b/f1/9e4bf184-6408-475c-7fbf-541729554181/7d7227eb-831f-443d-85a4-bc3104e15eb5__U666e_U901a_U5c4f.png/392x696bb.png
 );
 releaseNotes = - 新增门店类型标签透出;
 isVppDeviceBasedLicensingEnabled = 1;
 sellerName = Hangzhou cuisine Network Technology Co., Ltd.;
 averageUserRating = 3.1176499999999998102850895520532503724;
 advisories = (
 偶尔/轻微的烟酒或毒品使用或相关内容
 );
 }
 );
 }
 */
/*
 -(void)requestCheckUpdateWithAlert
 {
 [MBProgressHUD zx_showLoading];
 __weak __typeof(&*self)weakSelf = self;
 NSString *appId = @"1512313756";
 [ZXCheckAppItunesVersionManager checkAppStoreNewVersionWithAppleID:appId success:^(BOOL isHaveNewVersion,CAIItunesModel *itunesModel) {
 [MBProgressHUD zx_hideHUD];
 if (isHaveNewVersion) {
 [UIAlertController zx_presentGeneralAlertInViewController:weakSelf withTitle:[NSString stringWithFormat:@"发现新版本%@",itunesModel.version] message:itunesModel.releaseNotes cancelButtonTitle:@"取消" cancleHandler:nil doButtonTitle:@"确定" doHandler:^(UIAlertAction * _Nonnull action) {
 [UIApplication zx_openURLToItunesForApplicationIdentifier:appId];
 }];
 }else{
 [MBProgressHUD zx_showError:@"已经是最新版本了"];
 }
 
 } failure:^(NSError * _Nonnull error) {
 [MBProgressHUD zx_showError:error.localizedDescription toView:nil];
 }];
 }
 */
